class Deep {
    setFinder(finder) {
        this.finder = finder;
        return this;
    }
    run(obj, each) {
        this.each = each;
        this.loopFn(obj);
    }
    loopFn(obj, level = 0, offset = 0) {
        this.each(obj, level, offset);
        const next = this.finder(obj);
        if (Array.isArray(next)) {
            next.map((v, k) => this.loopFn(v, level + 1, k));
        } else if (typeof next === 'object' && next) {
            this.loopFn(next, level + 1, 0);
        }
    }
}